package ly.jobdu;

import java.util.Scanner;

public class Q1032ZOJ2 {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while (scanner.hasNext()) {
			String str = scanner.nextLine();
			if (str.equals("E")) {
				break;
			} else {
				zoj(str);
			}
		}
	}

	public static void zoj(String str) {
		char[] c = str.toCharArray();
		int countZ = 0, countO = 0, countJ = 0;
		for (int i = 0; i < c.length; i++) {
			if (c[i] == 'Z') {
				countZ++;
			} else if (c[i] == 'O') {
				countO++;
			} else if (c[i] == 'J') {
				countJ++;
			}
		}

		String output = "";

		if (countZ >= countO && countZ >= countJ) {
			for (int i = 1; i <= countZ; i++) {
				output = output + "Z";
				if (countO > 0) {
					output = output + "O";
					countO--;
				}
				if (countJ > 0) {
					output = output + "J";
					countJ--;
				}
			}
		} else if (countO > countZ && countO >= countJ) {
			for (int i = 1; i <= countO; i++) {
				if (countZ > 0) {
					output = output + "Z";
					countZ--;
				}
				output = output + "O";
				if (countJ > 0) {
					output = output + "J";
					countJ--;
				}
			}
		} else if(countJ > countZ && countJ > countO) {
			for (int i = 1; i <= countJ; i++) {
				if (countZ > 0) {
					output = output + "Z";
					countZ--;
				}
				if (countO > 0) {
					output = output + "O";
					countO--;
				}
				output = output + "J";
			}
		}
		
		System.out.println(output);
	}
}
